package com.lphl.pet.pager;

import android.app.AlertDialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.lphl.pet.R;
import com.lphl.pet.RoundProgressBar;
import com.lphl.pet.base.BasePager;

import java.util.List;

import cn.aigestudio.datepicker.interfaces.OnDateSelected;
import cn.aigestudio.datepicker.views.DatePicker;

public class DayPager extends BasePager implements View.OnClickListener {

    private ImageView iv_previous; // 上一日
    private ImageView iv_down_icon; // 下拉选择
    private ImageView iv_mood; // 心情图片
    private ImageView iv_next; // 下一日
    private TextView tv_pet_analyze_data; // 当前日期
    private TextView tv_pet_analyze_year_mon;
    private TextView tv_pet_analyze_week;
    private TextView tv_mood_num;
    private TextView tv_suport_num;
    private TextView tv_step_num; // 运动时间
    private TextView tv_rest_num;  // 休息时间
    private TextView tv_consume_num; // 卡路里
    private TextView tv_pet_power;  // 皇家狗粮能量值
    private TextView tv_sport_percentage_num; // 运动百分比
    private TextView tv_rest_percentage__num; // 休息百分比
    private RoundProgressBar roundProgressBar_suport;
    private RoundProgressBar roundProgressBar_reset;

    public DayPager(Context context) {
        super(context);
    }

    @Override
    public View initView() {
        view = View.inflate(context, R.layout.activity_pet_analyze_day, null);

        iv_previous = (ImageView) view.findViewById(R.id.iv_previous);
        iv_down_icon = (ImageView) view.findViewById(R.id.iv_down_icon);
        iv_mood = (ImageView) view.findViewById(R.id.iv_mood);
        iv_next = (ImageView) view.findViewById(R.id.iv_next);
        tv_pet_analyze_data = (TextView) view.findViewById(R.id.tv_pet_analyze_data);
        tv_pet_analyze_year_mon = (TextView) view.findViewById(R.id.tv_pet_analyze_year_mon);
        tv_pet_analyze_week = (TextView) view.findViewById(R.id.tv_pet_analyze_week);
        tv_mood_num = (TextView) view.findViewById(R.id.tv_mood_num);
        tv_suport_num = (TextView) view.findViewById(R.id.tv_suport_num);
        tv_step_num = (TextView) view.findViewById(R.id.tv_step_num);
        tv_rest_num = (TextView) view.findViewById(R.id.tv_rest_num);
        tv_consume_num = (TextView) view.findViewById(R.id.tv_consume_num);
        tv_pet_power = (TextView) view.findViewById(R.id.tv_pet_power);
        tv_sport_percentage_num = (TextView) view.findViewById(R.id.tv_sport_percentage_num);
        tv_rest_percentage__num = (TextView) view.findViewById(R.id.tv_rest_percentage__num);

        roundProgressBar_suport = (RoundProgressBar) view.findViewById(R.id.roundProgressBar_suport);
        roundProgressBar_reset = (RoundProgressBar) view.findViewById(R.id.roundProgressBar_reset);

        roundProgressBar_suport.setProgress(80);
        roundProgressBar_reset.setProgress(60);
        iv_down_icon.setOnClickListener(this);
        return view;
    }

    @Override
    public void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_down_icon:
                final AlertDialog dialog = new AlertDialog.Builder(context).create();
                dialog.show();
                final DatePicker datePicker = new DatePicker(context);
                datePicker.setColor(context.getResources().getColor(R.color.them_color));
                datePicker.setOnDateSelected(new OnDateSelected() {
                    @Override
                    public void selected(List<String> date) {
                        StringBuilder sb = new StringBuilder();
                        for(String s : date){
                            sb.append(s).append("\n");
                        }
                        Toast.makeText(context, sb.toString(),Toast.LENGTH_LONG).show();
                        dialog.dismiss();
                    }
                });
                ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams
                        .WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                dialog.getWindow().setContentView(datePicker, params);
                dialog.getWindow().setGravity(Gravity.CENTER);
                break;
        }
    }
}
